"use strict";
module.exports = /** @class */ (function () {
    function Matcher(html) {
        this.html = html;
        this.out = {};
        // this.html = html
    }
    Matcher.prototype.matchVar = function (key) {
        var result = this.html.match(new RegExp("var " + key + " = '(.+?)';"));
        if (result) {
            this.out[key] = result[1];
        }
        return this;
    };
    Matcher.prototype.matchDataVar = function (key) {
        var varName = this.html.match(new RegExp("'" + key + "':'?(\\w+)'?,"));
        if (varName) {
            var result = this.html.match(new RegExp("var " + varName[1] + " = '(.+?)';"));
            if (result) {
                this.out[key] = result[1];
            }
        }
        return this;
    };
    Matcher.prototype.matchData = function (key) {
        var result = this.html.match(new RegExp("'" + key + "':'?(\\w+)'?,"));
        if (result) {
            this.out[key] = result[1];
        }
        return this;
    };
    Matcher.prototype.matchObject = function (key) {
        var result = this.html.match(new RegExp(key + " : '(.+?)',"));
        if (result) {
            this.out[key] = result[1];
        }
        return this;
    };
    // 文件，带密码
    Matcher.prototype.matchPwdFile = function (key) {
        // type : 'post',
        // url : '/ajaxm.php',
        // data : 'action=downprocess&sign=BmABPw4_aDz4IAQA_aV2dRbVozAjVQPwExBTUHNVI2AzQAJgAjXDxXMglpAWcGZgI2Uz4CNlc_bAjYBMA_c_c&p='+pwd,
        // dataType : 'json',
        var result = this.html.match(new RegExp(key + " ?: ?'(.*?)'"));
        if (result) {
            this.out[key] = result[1];
        }
        return this;
    };
    Matcher.prototype.matchIframe = function (key) {
        if (key === void 0) { key = 'iframe'; }
        return this.match(key, '<iframe.*src="(\\/fn\\?\\w{5,})" ');
    };
    Matcher.prototype.matchTitle = function (key) {
        if (key === void 0) { key = 'title'; }
        var result = this.html.match(/<title>(.*?)<\/title>/);
        if (result) {
            this.out[key] = result[1].replace(' - 蓝奏云', '');
        }
        return this;
    };
    Matcher.prototype.matchSecondVerify = function () {
        var result = this.html.match(new RegExp("\tdata : (.*),"));
        if (result) {
            var objStr = result[1].replace(':el', ':1');
            var obj = eval("(" + objStr + ")");
            this.out['data'] = obj;
        }
        return this;
    };
    Matcher.prototype.match = function (key, pattern) {
        var result = this.html.match(new RegExp(pattern));
        if (result) {
            this.out[key] = result[1];
        }
        return this;
    };
    Matcher.prototype.done = function () {
        return this.out;
    };
    return Matcher;
}());
// module.exports = Matcher
